<html>
<head>
    
    <link rel="stylesheet" type="text/css" href="http://sport.rtl.de/formel1/ticker/f1ticker.css">
	
	<style type="text/css">
		body
		{
			margin: 0px 0px 0px 0px;
			padding: 0px 0px 0px 0px;
			width: 921px;
			height: 630px;
			font-family: verdana;
			font-weight: bold;
			font-size: 10px;
		}
		a
		{
			color: Black;
			text-decoration: none;
		}
		a:hover
		{
			text-decoration: underline;
		}
		img
		{
			border: 0px solid Black;
		}
		table, tr, td
		{
			margin: 0px 0px 0px 0px;
			padding: 0px 0px 0px 0px;
		}
		table.Menu
		{
			font: bold 10px verdana,geneva,arial,helvetica,sans-serif;
			margin-top: 23px;
			margin-bottom: 8px;
		}
		td.MenuSession
		{
			background-color: #9A0000;
			border-right: 2px solid White;
			padding: 5px 10px 7px 10px;
			color: White;
		}
		td.MenuTop
		{
			background-color: #d4d0c7;
			border-bottom: 1px solid White;
			border-left: 0px solid White;
			border-right: 2px solid White;
			padding: 5px 5px 5px 5px;
		}
		td.MenuBottom
		{
			background-color: #d4d0c7;
			border-top: 1px solid White;
			border-left: 0px solid White;
			border-right: 2px solid White;
			padding: 5px 5px 5px 5px;
		}
		td.MenuTopL
		{
			background-color: #d4d0c7;
			border-bottom: 1px solid White;
			border-left: 2px solid White;
			border-right: 0px solid White;
			padding: 5px 5px 5px 5px;
		}
		td.MenuBottomL
		{
			background-color: #d4d0c7;
			border-top: 1px solid White;
			border-left: 2px solid White;
			border-right: 0px solid White;
			padding: 5px 5px 5px 5px;
		}
		td.MenuImage
		{
			border: 1px solid #9A0000;
			margin-left: 2px;
			margin-right: 2px;
			text-align: center;
			vertical-align: middle;
			padding: 3px 2px 0px 2px;
		}
	</style>

	<script type="text/jscript" language="jscript">
		var tickerId = System.Gadget.Settings.readString("tickerId");
		var autoRefresh = System.Gadget.Settings.readString("autoRefresh");
		var singleRefresh = System.Gadget.Settings.readString("singleRefresh");
		
		var rankingView = 2;
		
		//var tickerId = 651;
		
		System.Gadget.Flyout.onShow = showFlyout;
		
		function showFlyout()
		{
			if (System.Gadget.docked) {
				document.getElementById("body").style.border = "1px solid #d4d0c7";
			}
			else {
				document.getElementById("body").style.border = "2px solid #d4d0c7";
			}
		}
		
		function updateHeader()
		{
		    getHeader("http://sport.rtl.de/formel1/ticker/hl1_" + tickerId + ".html?" + (new Date().getTime()));
		}
		
		function updateRanking()
		{
			var colorNormal = "#d4d0c7";
			var colorSel = "#fe3233";
			
			document.getElementById("cellKlassement").className = (rankingView == 2 ? "bgColorSport1 navigationTextOn navigationColumn navigationColumnSize2" : "bgColorNavigation navigationTextOff navigationColumn navigationColumnSize2");
			document.getElementById("cellWMStand").className = (rankingView == 4 ? "bgColorSport1 navigationTextOn navigationColumn navigationColumnSize2" : "bgColorNavigation navigationTextOff navigationColumn navigationColumnSize2");
			document.getElementById("cellStartaufstellung").className = (rankingView == 3 ? "bgColorSport1 navigationTextOn navigationColumn navigationColumnSize2" : "bgColorNavigation navigationTextOff navigationColumn navigationColumnSize2");

			document.getElementById("ifrRanking").src = "http://sport.rtl.de/formel1/ticker/i" + rankingView + "_" + tickerId + ".html?" + (new Date().getTime());
		}
		
		function updateNews()
		{
			document.getElementById("ifrNews").src = "http://sport.rtl.de/formel1/ticker/t_" + tickerId + ".html?" + (new Date().getTime());
		}
		
		function updateAll()
		{
			updateHeader();
			updateRanking();
			updateNews();
		}
		
		function updateTimer()
		{
			tickerId = System.Gadget.Settings.readString("tickerId");
			autoRefresh = System.Gadget.Settings.readString("autoRefresh");
			if(autoRefresh == 0)
				return;
				
			updateAll();
		}
		
		function singleRefreshTimer()
		{
			singleRefresh = System.Gadget.Settings.readString("singleRefreshFlyout");
			if(singleRefresh == 0)
				return;
			
			singleRefresh = 0;
			System.Gadget.Settings.write("singleRefreshFlyout", singleRefresh);
			
			if(System.Gadget.Settings.readString("tickerId") != tickerId)
				rankingView = 2;	
			
			tickerId = System.Gadget.Settings.readString("tickerId");
						
			var options = document.getElementById("selSession").options;
			for(var i = 0; i < options.length; i++) {
				if(options[i].value == tickerId) {
					options[i].selected = true;
					break;
				}
			}
			
			updateAll();
		}
		
		function sessionChanged()
		{
			var sel = document.getElementById("selSession");
			tickerId = sel.options[sel.selectedIndex].value;
			System.Gadget.Settings.write("tickerId", tickerId);
			
			rankingView = 2;
			
			System.Gadget.Settings.write("singleRefreshGadget", 1);
			updateAll();
		}
		
		function refreshTicker()
		{
			System.Gadget.Settings.write("singleRefreshGadget", 1);
			updateAll();
		}
		
		function changeRankingView(view)
		{
			rankingView = view;			
			updateRanking();
		}
		
        function getHeader(url) {
    		req = new ActiveXObject("MSXML2.XMLHTTP");
			
			if (req != undefined) {
				req.onreadystatechange = function() {getHeaderResponse(url);};
				req.open("GET", url, true);
				req.send("");
			}
		}  

		function getHeaderResponse(url) {
			if (req.readyState == 4) {
				if (req.status == 200) {
					
					var body = BinaryToString(req.responseBody);
					
					body = body.replace(/if \(location\.search\.length==14\) \{/gi, "if (location.search.length==14) { return;");
					body = body.replace(/onload="JavaScript:load_\(\);return false;"/gi, "");
					body = body.replace(/onclick="javascript:parent.frNavi.nachladen\(\);"/gi, "onclick=\"javascript:parent.refreshTicker();\"");
					body = body.replace(/img_new\/btnAktualisieren_sport\.gif/gi, "http://sport.rtl.de/formel1/ticker/img_new/btnAktualisieren_sport.gif");
					
					//alert(body);
					
					var doc = top.frames.ifrHeader.document;
					doc.write(body);
					
					doc.close();
				}
			}
		}
	    
	    function test()
	    {
	        alert("hi");
	    }	
	</script>

	<script type="text/vbscript" language="VBScript">
		' Solution found on http://www.codingforums.com/archive/index.php?t-47018.html
		
		Function BinaryToString(Binary)
			Dim I,S
			For I = 1 to LenB(Binary)
				S = S & Chr(AscB(MidB(Binary,I,1)))
			Next
			BinaryToString = S
		End Function
	</script>
</head>
<body style="border: 2px solid Gray;" id="body">
	<!-- This empty link exists to prevent the following select box getting the focus and having a selection border -->
	<a href=""></a>
	
	<table class="tableNavigation" cellpadding="0" cellspacing="0" border="0">
		<tr>
			<td class="column1">
				<img src="http://sport.rtl.de/formel1/ticker/img_new/header_f1_ticker_sport.jpg" width="575" height="89"/>
			</td>
			<td class="column2">
				<table cellpadding="0" cellspacing="0" border="0">
					<tr>
						<td class="bgColorSport2 navigationTextOff navigationColumn navigationColumnSize1">

							<FORM NAME="fmSelTick">
							Session ausw&auml;hlen:&nbsp;&nbsp;
							<SELECT id="selSession" class="selectSession" NAME="TickID" SIZE="1" onchange="sessionChanged();">
							</SELECT>
							</FORM>
																		
						</td>
					</tr>

				</table>
					
				<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" >
					<TR>
						<TD class="bgColorSport1 navigationTextOn navigationColumn navigationColumnSize2" ID="cellKlassement"><A ID="Link_2_Link" href="javascript:changeRankingView(2);">Live-Ergebnisse</A></TD>
						<TD class="bgColorNavigation navigationTextOff navigationColumn navigationColumnSize2" ID="cellStartaufstellung"><A ID="Link_3_Link" href="javascript:changeRankingView(3);">Startaufstellung</A></TD>
					</TR>
					<TR>
					    <TD class="bgColorNavigation navigationTextOff navigationColumn navigationColumnSize2" ID="Link_1"><A ID="Link_1_Link" href="javascript:window.location = 'http://sport.rtl.de/formel1/ticker/i1_' + tickerId + '.html?' + (new Date().getTime());">Streckeninfos</A></TD>

						<TD class="bgColorNavigation navigationTextOff navigationColumn navigationColumnSize2" ID="cellWMStand"><A ID="Link_4_Link" href="javascript:changeRankingView(4);">WM-Stand</A></TD>
					</TR>
				</TABLE>
							        		
			</td>		
		</table>


	<table width="100%" cellspacing="0">
		<tr>
			<td colspan="2">
				<iframe id="ifrHeader" style="border: 0px solid black; height: 55px;
					width: 922px; margin-bottom: 7px;" frameborder="0"></iframe>
			</td>
		</tr>
		<tr>
			<td>
				<iframe id="ifrRanking" style="border: 0px solid black; height: 370px; width: 452px;
					margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px;" frameborder="0"></iframe>
			</td>
			<td>
				<iframe id="ifrNews" security="restricted" style="border: 0px solid black; height: 370px;
					width: 483px; margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px;" frameborder="0">
				</iframe>
			</td>
		</tr>
		<tr>
			<td colspan="2" style="height: 115px;">
				<table width="98%" style="padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px;">
					<tr style="padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px;">
						<td align="center" valign="middle" style="padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px;">
							<a href="http://sport.rtl.de/formel1/streckenani/main.html" style="padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px;">
								<img src="http://sport.rtl.de/formel1/ticker/img_new/btn_streckeninfocenter.gif" alt="Strecken Inforcenter" style="padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px;"/></a>
						</td>
						<td align="center" valign="middle" style="padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px;">
							<a href="http://sport.rtl.de/games/webracer/index.php" style="padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px;">
								<img src="http://sport.rtl.de/formel1/ticker/img_new/btn_webracer.gif" alt="Webracer" style="padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px;"/></a>
						</td>
						<td align="center" valign="middle" style="padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px;">
							<a href="http://www.rtl.de/sport/formel-1/livestream/" style="padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px;">
								<img src="http://sport.rtl.de/formel1/ticker/img_new/btn_livestream.gif" alt="F1-Chat" style="padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px;"/></a>
						</td>						
					</tr>
				</table>
			</td>
		</tr>
	</table>

	<script type="text/jscript" language="jscript">
		updateAll();
		intervalRefresh = window.setInterval("updateTimer()", 5000);
		intervalSingleRefresh = window.setInterval("singleRefreshTimer()", 1000);
		
		var selThis = document.getElementById("selSession");
		var selOther = System.Gadget.document.getElementById("selSession");
		
		for(var i = 0; i < selOther.options.length; i++)
		{
			var optTemp = document.createElement("option");
			var optTempTxt = document.createTextNode(selOther.options[i].innerHTML);
			
			optTemp.setAttribute("value", selOther.options[i].getAttribute("value"));
			optTemp.setAttribute("selected", selOther.options[i].getAttribute("selected"));
			optTemp.appendChild(optTempTxt);
			
			selThis.appendChild(optTemp);
		}
		
		//System.Gadget.Settings.write("tickerId", 537);
		//
	</script>

</body>
</html>
